<?php
require_once("./DButil.php");
$username = $_REQUEST["username"];

$password = $_REQUEST["password"];

$sql = "select "
." teacherId,teacherName,username,password,status,roleId "
." from t_teacher "
." where username = '{$username}' "
." and password = '{$password}'";
$teacher = query($sql);
$t=$teacher[0];

$_SESSION["loginTeacher"]=$teacher;//记录登录老师状态

$result=[
    "msg"=>"登陆成功",
    "code"=>200,
    "success"=>true,
    "data"=>$teacher
];
if(!$t){
    $result=[
        "msg" => "用户名或密码错误",
        "code" => 500,
        "success" => false
    ];
}

header("Content-Type:application/json;charset=utf-8");
echo json_encode($result);


?>



